package com.example.myapplication.okHttp;

import java.util.Map;
import java.util.concurrent.Executor;

import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;

public interface HttpbinService {

    @POST("post")
    @FormUrlEncoded  ///以表单的方式
    Call<ResponseBody> post(@Field("username") String userName, @Field("password") String pwd);
//    Call<ResponseBody> post(@Body("json")) String json);

    @GET("get")
    @FormUrlEncoded
    Call<ResponseBody> get(@Query("username") String userName, @Query("password") String pwd);

    @HTTP(method = "GET",path = "get",hasBody = true) ///方式注解
    @FormUrlEncoded
    Call<ResponseBody> http(@QueryMap Map<String,String> map);

    @POST("post")
  //  @FormUrlEncoded  ///以表单的方式
    Call<ResponseBody> postBody(@Body RequestBody body);

    ///get @Query, post @Field

    @POST("{id}")
    @FormUrlEncoded
    Call<ResponseBody> postInPath(@Path("id") String path, @Header("os")String os, @Field("username") String userName, @Field("password") String pwd);

    ///请求头，多个参数
    @Headers({"os:android","version:1.0"})
    @POST("post")
    Call<ResponseBody> postWithHeaders();

    @POST
    Call<ResponseBody> postUrl(@Url String url);
}
